<?php Yii::app()->clientScript->registerScriptFile (Yii::app()->baseUrl.'/js/number/jquery.autotab-1.1b.js'); ?>

<script type="text/javascript">
	$(document).ready(function(){
		 $('#a_makepayment').attr('class','current');
		 $('#paypal').click(function(){
		 		if($(this).is(":checked")){
		 			 $('#show_box').hide();
		 		}
		 });
		 $('#cc').click(function(){
		 		if($(this).is(":checked")){
		 			 $('#show_box').show();
		 		}
		 });
		 
		 check_submit=function(){
		 		if(!$('#agree').is(":checked")){
		 			alert('<?php echo Yii::t('message','agree');?> ');
		 			return false;	
		 		}
		 		return true;
		 };
		 
		 redirect_account = function()
		 {
     		 window.location.href="<?php echo $this->createUrl('Account/index');?>";	
     	 };


     	 //VALIDATOR
     	jQuery('#TblCustomerPayment_creditCardNumber, #TblCustomerPayment_creditSecureCode, #TblCustomerPayment_cardHolderZipCode').autotab_magic().autotab_filter('numeric');
     	jQuery('#TblCustomerPayment_chargedAmount').autotab_magic().autotab_filter({ format: 'custom', pattern: '[^0-9\.]' });;
	});
		
</script>


<div class="bg_tt_page">
    <div class="my">My Account</div>
    <div class="ac"><?php echo Yii::t('account','Make Payment');?></div>
</div>
<div class="center_page_afterlogin">
    <div class="col_left">
        	<?php $this->renderPartial('//common/leftCustomer'); ?>
    </div>
    
    <div class="col_right">
		    <?php $form=$this->beginWidget('CActiveForm', array(
				'id'=> 'make_payment',
				'enableAjaxValidation'=>false,
			)); ?>
    
	        <div class=" p13l p12t p13b bo_b_d">
	        
		        <p> <?php echo Yii::t('account','Which type would you like to recharge ?');?></p>
		        
		        <div class="bg_check">
		        	<input id="cc" name="payment_method" type="radio" class="float_left" value="cc" checked="checked" />Credit Card
		        </div>
		        <div class="bg_check">
		        	<input id="paypal"  name="payment_method" class="float_left" type="radio" value="paypal"  />Paypal
		        </div>
		        <div class="cb"></div>
	        </div>
	        
	        
	        
	        <div class="box_makepayment ">
	        
	        	
				<div id="show_box">
			        <label><?php echo Yii::t('account','Credit Card Type');?></label>
			        <?php
						echo $form->dropDownList($model,'creditCardTypeID', 
									 	CHtml::listData(TblCreditCardType::model()->findAll(), 'creditCardTypeID', 'creditCardType'), 
									 	array('empty'=> Yii::t('common','-- Please select --'),'class' => 'w331')
									 );
					?>
			        <br class="cb" />
	
			        <label><?php echo Yii::t('account','Credit Card');?> # </label>
			        <?php echo $form->textField($model,'creditCardNumber',array('class' => 'box_makepayment_txt w325', 'maxlength'=>25)); ?>
			        <br class="cb" />
	
			        <label><?php echo Yii::t('account','Expiration Date');?></label>
			        <?php echo $form->dropDownList($model, 'creditExpireMonth', $model->ddMonths , array('class' => 'w162 float_left')); ?>
					<?php echo $form->dropDownList($model, 'creditExpireYear', $model->ddYears , array('class' => 'w162 float_left')); ?>		        
			        <br class="cb" />
	
			        <label><?php echo Yii::t('account','CVV Code');?> </label>
			        <?php echo $form->textField($model,'creditSecureCode',array('class' => 'box_makepayment_txt w156 float_left', 'maxlength'=>6)); ?>
			        <span style="position:relative; top:4px;">The Code is the last three digits on the back of the credit card.</span>
			        <br class="cb" />
	
			        <p class="p10b">
			        <label>&nbsp;</label>
			        <?php echo $form->checkBox($model,'checkbox',array(
						'ajax' => array(
							"id" => 'checkbox',
							"url" => array("Customer/AjaxLoadCustomer"),
							"success"=> "function(data){
								 var cb=$('#TblCustomerPayment_checkbox');
								 cb.attr('checked', !cb.is(':checked'));
								 if(data.success !== false){
								 		$('#TblCustomerPayment_cardHolderFirstName').val(data.firstName);
								 		$('#TblCustomerPayment_cardHolderLastName').val(data.lastName);
								 		$('#TblCustomerPayment_cardHolderAddress').val(data.address);
								 		$('#TblCustomerPayment_cardHolderCity').val(data.city);
								 		$('#TblCustomerPayment_cardHolderStateID').val(data.stateID);
								 		$('#TblCustomerPayment_cardHolderZipCode').val(data.zipCode);
								 }
								 
							}",
							'return' => true,
						)
					
					));?>
					
					
			        <?php echo Yii::t('account','Click here if the name and billing address are the same as provided for the account');?></p>
			        <label><?php echo Yii::t('profile','First Name');?>:</label>
			        <?php echo $form->textField($model,'cardHolderFirstName',array('class' => 'box_makepayment_txt w325', 'maxlength'=>50)); ?>
			        <br class="cb" />
	
			        <label><?php echo Yii::t('profile','Last Name');?>:</label>
			        <?php echo $form->textField($model,'cardHolderLastName',array('class' => 'box_makepayment_txt w325', 'maxlength'=>50)); ?>
			        <br class="cb" />
			        
			        
			        <label><?php echo Yii::t('profile','Address');?>:</label>
			        <?php echo $form->textField($model,'cardHolderAddress',array('class' => 'box_makepayment_txt w325', 'maxlength'=>50)); ?>
			        <br class="cb" />
			        
			        <label><?php echo Yii::t('profile','City');?>:</label>
			        <?php echo $form->textField($model,'cardHolderCity',array('class' => 'box_makepayment_txt w325', 'maxlength'=>50)); ?>
			        <br class="cb" />
			        
			        <label><?php echo Yii::t('profile','State');?>:</label>
			        <?php
						echo $form->dropDownList($model,'cardHolderStateID', 
								 	CHtml::listData(TblStateZip::model()->findAll(), 'stateID', 'stateName'),
								 	array('empty'=> Yii::t('common','-- Please select --'),'class' => 'w331')
							);
					?>
			        <br class="cb" />
			        
			        <label><?php echo Yii::t('profile','Zip Code');?>:</label>
			        <?php echo $form->textField($model,'cardHolderZipCode',array('class' => 'box_makepayment_txt w325', 'maxlength'=>10)); ?>
			        <br class="cb" />
			    </div><!-- #show-box -->
		        
		        <label><?php echo Yii::t('account','Amount');?> $:</label>
		        <?php echo $form->textField($model,'chargedAmount',array('class' => 'box_makepayment_txt w325', 'maxlength'=>50)); ?>
		        <br class="cb" />
		        
		        <label>&nbsp;</label>
		        <p class="p10b float_left">
					<input type="checkbox" name="agree" value="1" id="agree" <?php if(isset($_POST['agree']) && $_POST['agree']==1):?>checked=true<?php endif;?>/>
					<?php echo Yii::t('account','term_condition',array(
						'{link}' => $this->createUrl('site/page',array('view' => 'TermsAndCondition')
					)));?>
					
					<br/>
					<?php echo Yii::t('account','payment_note');?>
		        </p>
		        <br class="cb" />

		        <label>&nbsp;</label>
		        <div class="p10b float_left">
		        <?php echo $form->errorSummary($model); ?>
		        </div>
		        <br class="cb" />
		        
		        <div class="p190l p10t"> 
					<?php echo CHtml::linkButton(Yii::t('account','Submit'),array(
										'name' => 'submit_payement',
										'class' => 'bt_submit float_left',
										'onclick' => 'if(!check_submit()) return false;'
					
					)); ?>
					
					<?php echo CHtml::link(Yii::t('account','Cancel'), array('customer/makePayment'), array('class' => 'bt_submit m10l float_left', ));?>
					<p class="cb"></p>
				</div>
				
				<?php $this->endWidget(); ?>
	      </div>
	      <?php
			    Yii::app()->clientScript->registerScript(
			       'myHideEffect',
			       '$(".flash-success").animate({opacity: 1.0}, 3000).fadeOut("slow");
			       	$(".flash-error").animate({opacity: 1.0}, 3000).fadeOut("slow");
			       	$(".flash-notice").animate({opacity: 1.0}, 3000).fadeOut("slow");
			       ',
			       CClientScript::POS_READY
			    );
			?>
			<?php if(Yii::app()->user->hasFlash('makepayment-success')): ?>
				<div class="flash-success">
					<?php echo Yii::app()->user->getFlash('makepayment-success'); ?>
				</div>
			<?php endif; ?>
			
			<?php if(Yii::app()->user->hasFlash('makepayment-error')): ?>
				<div class="flash-error">
					<?php echo Yii::app()->user->getFlash('makepayment-error'); ?>
				</div>
			<?php endif; ?>
			
			<?php if(Yii::app()->user->hasFlash('makepayment-notice')): ?>
				<div class="flash-notice">
					<?php echo Yii::app()->user->getFlash('makepayment-notice'); ?>
				</div>
			<?php endif; ?>
	      
    </div><!-- #col_right -->
	<div class="cb"></div>
</div>
<div class="bottom_pages_afterlogin"></div>   